package com.web.boot.web.log;

import com.blue.core.dict.HttpMethod;
import com.blue.core.dict.annotation.DictParser;
import com.blue.http.annotation.Http;
import com.blue.http.message.HttpRequest;
import com.blue.http.message.View;
import com.web.base.log.facade.SmsFacade;
import com.web.base.log.message.SmsRequest;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * 短信日志控制器
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2017年11月21日
 */
@Controller("logSmsController")
@Http(url = "/log")
public class SmsController
{
	@Autowired
	private SmsFacade smsFacade;
	
	private static DictParser parser = DictParser.getInstance();
	
	public SmsController()
	{
	}

	@Http(url = "/sms_list", method = HttpMethod.GET)
	public View listGet(HttpRequest request)
	{
		SmsRequest smsRequest = request.getQueryObject(SmsRequest.class);
		return View.createBuilder().setView("log/sms_list")
				.put("model", request)
				.put("page", smsFacade.listPage(smsRequest, Const.PAGE_START, Const.PAGE_SIZE))
				.put("map", parser.getStringMap())
				.build();
	}
	
	@Http(url = "/sms_list", method = HttpMethod.POST)
	public View listPost(HttpRequest request)
	{
		SmsRequest smsRequest = request.getPostObject(SmsRequest.class);
		int start = request.getPostInt("start", Const.PAGE_START);
		return View.createBuilder().setView("/log/sms_list_grid")
				.put("page", smsFacade.listPage(smsRequest, start, Const.PAGE_SIZE))
				.build();
	}
	
}
